/* 
 * File:   PointsAdapter.h
 * Author: Guilherme Monteiro
 *
 */

#ifndef GENERICADAPTER_H
#define	GENERICADAPTER_H
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>

#include <exception>
#include <cerrno>

#include "NullImageException.h"
#include "MetaInfo.h"
#include "Cell.h"

using namespace std;

enum AdaptationType {LOW_2_HIGH, HIGH_2_LOW};

/**
 * Class that represents an generic adapter of points and cells,
 * it's must to convert the points/cells between
 * the low and high resolution.
 * 
 * @author Guilherme Monteiro
 * 
 */
class GenericAdapter {
public:
    GenericAdapter(AdaptationType adaptationType, MetaInfo* metainfo) throw (NullImageException);
    GenericAdapter(const GenericAdapter& orig);
    virtual ~GenericAdapter();
    
    vector<CvPoint> adaptPoints(vector<CvPoint> points);
    vector<Cell> adaptCells(vector<Cell> cells);
    CvPoint adaptPoint(CvPoint point);
private:
    AdaptationType adaptationType;
    MetaInfo* metaInfo;
    
    double adaptationHorizontalTax;
    double adaptationVerticalTax;
    
    void configureAdapter() throw (NullImageException);
    
    void setAdaptationType(AdaptationType type);
    AdaptationType getAdaptationType();
    
    void setMetaInfo(MetaInfo* meta);
    MetaInfo* getMetaInfo();
    
    vector<CvPoint> transformCellsToPoints(vector<Cell> cells);
};

#endif	/* GENERICADAPTER_H */

